<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\business\BusinessPerson */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '业务人员', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
              <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">

                <div class="business-person-view">

                    <p>
                        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
                        <?= Html::a('删除', ['delete', 'id' => $model->id], [
                            'class' => 'btn btn-danger',
                            'data' => [
                                'confirm' => '您确定删除此项吗?',
                                'method' => 'post',
                            ],
                        ]) ?>
                    </p>

                    <?= DetailView::widget([
                        'model' => $model,
                        'attributes' => [
                            'id',
                            'name',
                            'gender',
                            'phone',
                            'descripation',
                            [
                                'attribute' => 'avatar',
                                'format' => 'raw',
                                'value' => function($model){
                                    return Html::img($model->fans?$model->fans->avatar:'',['width'=>'80px']);
                                }
                            ],
                            [
                                'attribute' => 'identity_img',
                                'format' => 'raw',
                                'value' => function($model){
                                    $pics = \common\components\Upload::checkGetUrl($model->identity_img,true,'identity_img');
                                    $html = '';
                                    foreach ($pics as $key => $row){
                                        $html .= Html::img($row,['width'=>'200px','style'=>'margin-right:10px;']);
                                    }
                                    return $html;
                                }
                            ],
                            'identityno',
                            [
                                'attribute' => 'status',
                                'value' => function($model){
                                    return \common\models\business\BusinessPerson::$status[$model->status];
                                }
                            ],
                            [
                                'attribute' => 'createtime',
                                'format' => ['date','php:Y-m-d H:i:s']
                            ],
                            [
                                'attribute'=>'pigs',
                                'format'=>'raw',
                                'value'=>function($model){
                                    $html = '';
                                    foreach ($model->pigs as $key => $row){
                                        $html .= Html::label($row->no,'',['class'=>'btn btn-default btn-xs','style'=>'margin-right:10px;']);
                                    }
                                    return $html;
                                }
                            ],
                        ],
                    ]) ?>

                </div>
            </div>
        </div>
    </section>
</section>